package com.housekeeping.housekeeping.usermanagement.dao.impl;

import com.housekeeping.housekeeping.usermanagement.entity.InformationUser;
import com.housekeeping.housekeeping.usermanagement.utils.DBManager;


import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/*
* 对数据库进行更改
* */
public class UpDateDao extends OperationDaoImpl {

    @Override
    public int upDate(InformationUser information) throws SQLException {
        Connection connection = DBManager.getConnection();
        String sql="update order_user set phone=?,wechat=?,datetime=? where name=?";
        PreparedStatement preparedStatement=connection.prepareStatement(sql);
        preparedStatement.setObject(1,information.getPhone());
        preparedStatement.setObject(2,information.getWechat());
        preparedStatement.setObject(3, Date.valueOf(information.getDatetime()));
        preparedStatement.setObject(4,information.getName());
        int i = preparedStatement.executeUpdate();
        DBManager.close(connection,preparedStatement);
        return i;

    }

}
